package com.cloudeye.business.mq.config;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

/**
 * @Author: lafangyuan
 * @Date: 2021/12/8 10:33
 */
public class RabbitMqPropertiesProcessor  implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        RabbitMqMsgTypeEnum[] types = RabbitMqMsgTypeEnum.values();
        String rootClassName =  RabbitMqMsgTypeEnum.class.getName();
        for(RabbitMqMsgTypeEnum type:types){
            beanFactory.registerSingleton(rootClassName+"."+type.toString()+".exchange",type.getExchange().toString());
            beanFactory.registerSingleton(rootClassName+"."+type.toString()+".routingKey",type.getRoutingKey().toString());
        }
    }
}
